package main

import (
	"fmt"
	"gee/gee"
	"log"
	"net/http"
	"time"
)

func main() {
	e := gee.NewEngine()
	r1 := e.Group("/w")
	r1.Get("/hello", helloIndex)

	r2 := e.Group("/v2")
	r2.Use(gee.Logger())
	r2.Get("/hello/:name", onlyForV2())
	e.Run(":8089")
}

func helloIndex(c *gee.Context) {
	names := []string{"geektutu"}
	c.String(http.StatusOK, names[100])
	fmt.Println("hello")
}
func onlyForV2() gee.HandlerFunc {
	return func(c *gee.Context) {
		// Start timer
		t := time.Now()
		// if a server error occurred
		fmt.Println("asdasd")
		// Calculate resolution time
		log.Printf("[%d] %s in %v for group v2", 500, c.Req.RequestURI, time.Since(t))
	}
}
